
<!-- 帆软BI及报表展示 -->
<template>
  <div class="link-home" v-loading='loading' element-loading-text="权限查询中">
    <div id="iframe-container">
      <iframe :src="link" scrolling="auto" frameborder="0" id="iframe"></iframe>
    </div>
    <!-- <div class="tipFault" v-if="noShow">
      <span>该系统尚未授权，请联系管理员授权登录!</span>
    </div> -->
    <!-- <el-dialog :visible="noShow" width="30%"  title="提示" :close-on-click-modal='false' :close-on-press-escape='false' :show-close='false'>
        <span>该系统尚未授权，请联系管理员授权登录!</span>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="toIndex">确 定</el-button>
      </span>
    </el-dialog> -->
  </div>
</template>

<script>
//import NProgress from 'nprogress'

export default {
  data() {
    return {
      loading: false,
      frameShow: false,
      noShow: false,
      title: "",
      link: "",
    }
  },
  activated() {
    // this.link = ''
   // if (this.$store.state.app.searchResouce == "menu") {
    let platform = navigator.userAgent;
    if (platform.indexOf("Electron") == -1) { //web端时跳转回上一页
      this.link = ''
      this.$router.back(-1)
      return
    }else{
      this.frameShow = false
      this.noShow = false
      this.link = ''
      this.title = this.$route.meta.title;
      switch (this.$route.meta.title) {
        case '铁道口监控系统':
          this.toOtherSystem()
          break
        default:
          this.link = this.$route.meta.link;
      }
    }

    //}
  },
  //   watch: {
  //     $route: function (to) {
  //        switch (this.$route.meta.title){
  //       case '铁道口监控系统':
  //         this.toOtherSystem()
  //         break
  //       default:
  //         this.title = this.$route.meta.title;
  //         this.link = this.$route.meta.link;
  //     }
  //       // console.log(this.$route.meta.title);
  //       //   this.title = this.$route.meta.title;
  //       //   this.link = this.$route.meta.link;
  //         // if(this.link)
  //         // {
  //         //  this.initData();
  //         // }

  //     }

  //   },
  methods: {
    //toIndex
    toIndex() {
      this.noShow = false
      this.$router.push({ name: 'home' })
    },
    //第三方子系统
    toOtherSystem() {
      this.loading = true
      this.$http.get(`/${this.$ServiceName}/api/external/authorization/v1/selectstatusbyid`, { params: { systemCode: 'TDK' } }).then(res => {
        this.loading = false
        if (res.data.success) {
          if (res.data.data.is_authorize == '0') {
            // this.title = this.$route.meta.title;
            this.frameShow = true
            setTimeout(()=>{
              this.link = 'http://192.168.75.168:999/iotfc/authorize?authToken=' + res.data.data.token.replace(/\+/g, "%2B");
            },500)
            // this.$message.success('登录成功')
          }
          else {
            this.noShow = true
            // this.$message.error('该系统未授权，请授权登录！')
          }
        } else {
          this.noShow = true
          //   this.$message.error('该系统未授权，请授权登录！')
        }
      }).catch(err => {
        this.loading = false
      })
    }
  },
  deactivated(){
    this.link = ''
  }
}
</script>
<style lang="less" scoped>
.tipFault {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  span {
    background: #eaeaea;
    font-size: 50px;
    color: white;
    text-shadow: 1px 1px black, -1px -1px black, 1px -1px black, -1px 1px black;
  }
}
.link-home {
  width: 100%;
  height: 100%;
}
#iframe-container {
  width: 100%;
  height: 100%;
}
#iframe {
  width: 100%;
  height: 100%;
}
</style>